/*
day290
2020.6.13
*/
#include<vector>
#include<iostream>
using namespace std; 

class Solution {
public:
    int heightChecker(vector<int>& heights) {
		int arr[101]={0};
		for(int i=0;i<heights.size();++i)
		{
			arr[heights[i]]++;
		}
		
		int res=0;
		
		int index=0;
		for(int i=1;i<101;++i)
		{
			while(arr[i] > 0)
			{
				if(heights[index]!=i)
				{
					res++;
				}
				index++;
				arr[i]--;
			}
		}
		
		return res;
    }
};




int main()
{
	vector<int> heights={1,1,4,2,1,3};
	Solution s;
	cout<<s.heightChecker(heights)<<endl;
	return 0;
}
